import request from '@/utils/request'
import cookie from 'js-cookie'
export default {
    getPageList(pageNum, pageSize, searchObj) {
        return request({
            url: `/eduservice/course/selectPageCourse/${pageNum}/${pageSize}`,
            method: 'post',
            data: searchObj
        })
    },
    // 获取课程二级分类
    getNestedTreeList2() {
        return request({
            url: `/eduservice/subject/getAllSubject`,
            method: 'get'
        })
    },
    // 根据课程id查询课程的详细信息
    getById(courseId) {
        return request({
            url: `/eduservice/course/selectCourseDetail/${courseId}`,
            method: 'get'
        })
    },
    collectCourse(courseId) {
        return request({
            url: `/eduservice/course/collect/${courseId}`,
            method: 'post',
            headers: {
                'token': cookie.get('youth_token')
            },
        })
    },
    // 检查课程是否已经被收藏
    checkCollect(courseId) {
        return request({
            url: `/eduservice/course/collect/${courseId}`,
            method: 'get',
            headers: {
                'token': cookie.get('youth_token')
            },
        })
    },
    // 根据课程id和用户id判断该用户是否具有操作权限
    selectAuthority(courseId,memberId) {
        return request({
            url: `/eduservice/coursemember/selectAuthority/${courseId}/${memberId}`,
            method: 'get'
        })
    },
    // 查询我的收藏，分页查询
    getCollectList(pageNum,pageSize){
        return request({
            url:`/eduservice/course/collect/${pageNum}/${pageSize}`,
            method:'get',
            headers: {
                'token': cookie.get('youth_token')
            },
        })
    },
    // 取消收藏对应课程
    cancelCollect(collectId){
        return request({
            url:'/eduservice/course/collect/'+collectId,
            method:'delete',
        })
    },
    setTop(collectId){
        return request({
            url:'/eduservice/course/collect/'+collectId,
            method:'put'
        })
    }
}
